package com.baibei.ebec.welfare.campaign;

import android.app.FragmentTransaction;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.FrameLayout;
import android.widget.TextView;

import com.baibei.ebec.home.R;
import com.baibei.ebec.home.R2;
import com.baibei.ebec.welfare.fragment.LotteryFragment;
import com.baibei.ebec.welfare.fragment.ShareFragment;
import com.baibei.ebec.welfare.fragment.SignFragment;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

public class DailyActivity extends AppCompatActivity {

    @BindView(R2.id.tv_sign)
    TextView tvSign;
    @BindView(R2.id.tv_lottery)
    TextView tvLottery;
    @BindView(R2.id.tv_share)
    TextView tvShare;
    @BindView(R2.id.fragment)
    FrameLayout fragment;
    private SignFragment signFragment;
    private LotteryFragment lotteryFragment;
    private ShareFragment shareFragment;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_daily);
        ButterKnife.bind(this);
        initView();
    }

    private void initView() {
        signFragment = new SignFragment();
        lotteryFragment = new LotteryFragment();
        shareFragment = new ShareFragment();

        FragmentTransaction fmt = getFragmentManager().beginTransaction();
        fmt.add(R.id.fragment, signFragment)
                .add(R.id.fragment, lotteryFragment)
                .add(R.id.fragment, shareFragment)
                .hide(lotteryFragment)
                .hide(shareFragment)
                .commit();
    }

    @OnClick({R2.id.tv_sign, R2.id.tv_lottery, R2.id.tv_share})
    public void onViewClicked(View view) {
//        switch (view.getId()) {
//            case R.id.tv_sign:
//                break;
//            case R.id.tv_lottery:
//                break;
//            case R.id.tv_share:
//                break;
//        }
        if (view.getId() == R.id.tv_sign){
            getFragmentManager().beginTransaction()
                    .hide(lotteryFragment)
                    .hide(shareFragment)
                    .show(signFragment)
                    .commit();
        } else if (view.getId() == R.id.tv_lottery){
            getFragmentManager().beginTransaction()
                    .hide(signFragment)
                    .hide(shareFragment)
                    .show(lotteryFragment)
                    .commit();
        } else {
            getFragmentManager().beginTransaction()
                    .hide(signFragment)
                    .hide(lotteryFragment)
                    .show(shareFragment)
                    .commit();
        }
    }
}
